import requests
import pytest
import csv
def read_csv():
    testdata=[]
    with open('date.csv',mode='r',encoding='utf8')as file:
        rd = csv.reader(file)
        next(rd)
        for line in rd:
            testdata.append(tuple(line))

    return testdata
testdata = read_csv()
print(testdata)

@pytest.mark.parametrize("username,passwd,excpet_code,excpet_msg",testdata)
def test_login(username,passwd,excpet_code,excpet_msg):
    url = "http://49.233.108.117:28019/api/v1/user/login"
    body = {
        "loginName": username,
        "passwordMd5": passwd
    }
    # 发送请求
    r = requests.post(url,json=body)
    print(r.json())
    # 添加断言
    assert r.json()["resultCode"] == int(excpet_code)
    assert r.json()["message"] == excpet_msg